package com.jzo2o.orders.dispatch.strategys;

import com.jzo2o.orders.dispatch.model.dto.ServeProviderDTO;

import java.util.Arrays;
import java.util.List;

/**
 * 策略模式测试类
 */
public class RuleHandlerTest2 {
    public static void main(String[] args) {
        // 创建测试数据
        List<ServeProviderDTO> serveProviderDTOS = Arrays.asList(
                ServeProviderDTO.builder().id(3L).acceptanceDistance(10).acceptanceNum(2).build(),
                ServeProviderDTO.builder().id(4L).acceptanceDistance(10).acceptanceNum(3).build(),
                ServeProviderDTO.builder().id(5L).acceptanceDistance(13).acceptanceNum(1).build(),
                ServeProviderDTO.builder().id(6L).acceptanceDistance(13).acceptanceNum(1).build()
        );

        //获取距离优先策略
//        IProcessStrategy processStrategy = new DistanceStrategyImpl();
        IProcessStrategy processStrategy = new LeastAcceptOrderStrategyImpl();
        //通过策略bean进行匹配处理
        ServeProviderDTO precedenceServeProvider = processStrategy.getPrecedenceServeProvider(serveProviderDTOS);
        System.out.println(precedenceServeProvider);
    }
}
